from time import sleep
from cases.base_case import BaseTestCase
from pages.base_page import BasePage
from selenium.webdriver.support.wait import WebDriverWait
from selenium.common.exceptions import (ElementNotVisibleException,
                                        ElementNotSelectableException,NoSuchElementException)



# 弹窗处理
# 创建等待类
class Wait(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    def wait_for_element(self, locator, timeout=10, poll_frequency=0.5):
        wait = WebDriverWait(self.driver, timeout, poll_frequency, ignored_exceptions=[ElementNotVisibleException,
    ElementNotSelectableException,
    NoSuchElementException])
        return wait.until(lambda x: x.find_element(*locator))
